package com.fdb.efp.flow.enumeration;

import java.util.Arrays;
import java.util.Objects;

import com.fdb.efp.flow.common.enumeration.NodeExecuteType;

/**
 * 
 * 执行beanid
 * 
 * @author Cytus_
 * @since 2018年5月29日 下午5:17:03
 * @version 1.0
 *
 */
public enum NodeExecuteTypeBean {
	
	NATURE_BEAN(new NodeExeTypeBean("nodeExecutor", NodeExecuteType.NATURE)), 
	PAGE_SUBMIT_BEAN(new NodeExeTypeBean("pageTaskSubmitExecutor", NodeExecuteType.PAGE_SUBMIT));
	
	private NodeExeTypeBean value;
	
	private NodeExecuteTypeBean(NodeExeTypeBean value) {
		this.value = value;
	}
	
	public NodeExeTypeBean getValue() {
		return this.value;
	}
	
	public static NodeExecuteTypeBean getNodeExecuteTypeBean(NodeExecuteType type) {
		return Arrays.stream(NodeExecuteTypeBean.values()).filter(s -> s.getValue().getType().equals(type)).findFirst().orElse(null);
	}
	
	public static String getNodeExecuteTypeBeanId(NodeExecuteType type) {
		NodeExecuteTypeBean bean = getNodeExecuteTypeBean(type);
		if (Objects.nonNull(bean))
			return bean.getValue().getBeanId();
		return null;
	}
	
	static class NodeExeTypeBean {
		private NodeExecuteType type;
		private String beanId;
		
		public NodeExeTypeBean(String beanId, NodeExecuteType type) {
			super();
			this.type = type;
			this.beanId = beanId;
		}
		
		public NodeExecuteType getType() {
			return type;
		}
		public void setType(NodeExecuteType type) {
			this.type = type;
		}
		public String getBeanId() {
			return beanId;
		}
		public void setBeanId(String beanId) {
			this.beanId = beanId;
		}
	}

}
